<?php
/**
 * Created by JetBrains PhpStorm.
 * User: linhpv
 * Date: 2/17/14
 * Time: 5:30 PM
 * To change this template use File | Settings | File Templates.
 */
class Param
{
    const  GUEST = 0;
    const  AUTHENTICATED = 1;
    const  PREMIUM = 2;
    const  LENGTH_DESCRIPTION_GUEST = 20;
    const  LENGTH_DESCRIPTION_AUTHEN = 20;
    const  LENGTH_TITLE_GUEST = 10;
    const  LENGTH_TITLE_AUTHEN = 10;
    const  SHOW_NUMBER_PROJECT_GUEST = 5;
    const  SHOW_NUMBER_PROJECT_AUTHEN = 10;
    const  TRANS_TYPE_PARTIAL_PRICE=1;
    const  TRANS_TYPE_FULL_PRICE=2;
    // role
    const ROLE_ADMIN = "ADMIN";
    const ROLE_AUTHEN = "AUTHENTICATED";
    const ROLE_PREMIUN = "PREMIUM";
    // transaction status
    const TRANS_STATUS_BUYING=0;
    const TRANS_STATUS_BUYED=1;
    const TRANS_STATUS_CANCEL=2;
    // transaction type


    public static function limitWord($value,$limit)
    {
        $words = preg_split("/[\s,.]+/", $value);
        $return = '';
        foreach ($words as $index => $word) {
            if ($index == 0) {
                $return = $word;
            } else if ($index <= $limit) {
                $return = $return . ' ' . $word;
            }

        }
        return $return;
    }
}